<?php


namespace app\crontab\controller\always;


use app\crontab\model\House;
use think\console\Command;
use think\console\Input;
use think\console\Output;

/**
 * 取消结束的重点房源
 * Class CancelImportant
 * @package app\crontab\controller
 */
class CancelImportant extends Command {

    protected function configure() {
        $this->setName('CancelImportant');
    }

    protected function execute(Input $input, Output $output) {
        $this->initial();
    }

    public function initial() {
        echo "runing\n";
        $model = new House();
        //取消是重点但不是待开始房源
        $model->alias('h')
            ->leftJoin('house_auction ha', 'ha.id=h.auction_id')
            ->where('h.important', 1)
            ->where('ha.auction_status', '<>', 1)
            ->update(['h.important' => 0]);
    }

}